package edu.webarchitechture.bank.ejb3.services;

import edu.webarchitechture.bank.ejb3.domain.User;

import javax.ejb.Stateless;
import javax.persistence.PersistenceContext;
import java.util.List;

import org.hibernate.Session;

/**
 * User Manager Bean.
 *
 * @author Inoka Dissanayaka.
 */
@Stateless
public class UserManagerBean implements UserManager {
    @PersistenceContext
    Session session;
    
    public User getUserById(Long userId) {
        return getUserManagerDAO().getUserById(userId);
    }

    public List<User> getAllUsers() {
        return getUserManagerDAO().getAllUsers();
    }

    public void saveUser(User user) {
        getUserManagerDAO().saveUser(user);
    }

    public void removeUser(User user) {
        getUserManagerDAO().removeUser(user);
    }

    /**
     * Returns a user manager DAO.
     *
     * @return a UserManagerDAO
     */
    public UserManagerDAO getUserManagerDAO() {
        return new UserManagerDAO(session);
    }
}
